﻿namespace ACCOUNTING.LVY.Business
{
    using ACCOUNTING;
    using Microsoft.VisualBasic;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Data;
    using System.Runtime.CompilerServices;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;

    public class clsDMTaiKhoan
    {
        private int mBoPhan = 0;
        private int mCapDo = 0;
        private int mCongNo = 0;
        private int mDoiTuongCungCap = 0;
        private int mDoiTuongKhachHang = 0;
        private int mDoiTuongNganHang = 0;
        private int mDoiTuongNhanVien = 0;
        private int mHopDong = 0;
        private string mKhoa = "";
        private string mLoaiPhienBan = "";
        private string mLoaiTaiKhoan = "";
        private string mLoaiTien = "";
        private string mNhomTaiKhoan = "";
        private string mPhanLoai = "";
        private int mSanPham = 0;
        private string mSoTaiKhoan = "";
        private int mTaiKhoanGiaThanh = 0;
        private string mTenAnh = "";
        private string mTenViet = "";
        private int mTheoDoiTheoDoiTuong = 0;
        private int mTonQuy = 0;

        public bool AddTKChiPhi(string pKhoaTK, string pSoTK)
        {
            string commandText = " INSERT INTO GL_TaiKhoanChiPhiTraTruoc(KhoaTaiKhoan, SoTaiKhoan) Values ('" + pKhoaTK.Trim() + "','" + pSoTK.Trim() + "')";
            return (DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]) > 0);
        }

        public void ClearAll()
        {
            this.mKhoa = "";
            this.mPhanLoai = "";
            this.mCapDo = 0;
            this.mNhomTaiKhoan = "";
            this.mSoTaiKhoan = "";
            this.mTenViet = "";
            this.mTenAnh = "";
            this.mBoPhan = 0;
            this.mSanPham = 0;
            this.mHopDong = 0;
            this.mCongNo = 0;
            this.mTonQuy = 0;
            this.mTheoDoiTheoDoiTuong = 0;
            this.mDoiTuongNhanVien = 0;
            this.mDoiTuongNganHang = 0;
            this.mDoiTuongCungCap = 0;
            this.mDoiTuongKhachHang = 0;
            this.mLoaiTien = "";
            this.mLoaiTaiKhoan = "";
            this.mTaiKhoanGiaThanh = 0;
        }

        public bool CodeWasUsed(string pKhoa)
        {
            string commandText = "SELECT TOP 1 * FROM DM_TaiKhoan WHERE NhomTaiKhoan = '" + pKhoa + "'";
            IDataReader reader = DBHelper.ExecuteReader(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]);
            if (reader.Read())
            {
                return true;
            }
            reader.Close();
            commandText = "SELECT top 1 * FROM GL_NhatKyChungTu WHERE KhoaTaiKhoanNo = '" + pKhoa + "' OR KhoaTaiKhoanCo = '" + pKhoa + "'";
            reader = DBHelper.ExecuteReader(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]);
            if (reader.Read())
            {
                return true;
            }
            reader.Close();
            return false;
        }

        public bool DelData(string pKhoa)
        {
            bool flag=false;
            IDataParameter[] commandParameters = new IDataParameter[2];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@Khoa", DbType.Int64, ParameterDirection.Input, pKhoa);
                commandParameters[1] = DBHelper.createParameter("@pError", DbType.Double, ParameterDirection.Output, 0);
                int num = DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "sp_DM_TaiKhoanDel", commandParameters);
                if (Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectNotEqual(commandParameters[1].Value, 0, false))
                {
                    return false;
                }
                flag = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public bool DelTKChiPhi(string pKhoaTK)
        {
            string commandText = " DELETE FROM GL_TaiKhoanChiPhiTraTruoc WHERE KhoaTaiKhoan = '" + pKhoaTK.Trim() + "'";
            return (DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]) > 0);
        }

        public DataTable GetList()
        {
            DataTable table;
            string commandText = "";
            IDataParameter parameter = null;
            try
            {
                commandText = "SELECT * FROM DM_TaiKhoan WHERE Rtrim(LoaiPhienBan) IN ('" + modGeneral.H_PHIENBANQUYETDINH + "', 'DC') ORDER BY SoTaiKhoan, CapDo ";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[] { parameter }).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public string GetListKhoaTaiKhoanCon(string strKhoaCha)
        {
            string commandText = "SELECT Khoa FROM DM_TaiKhoan WHERE RTRIM(ISNULL(NhomTaiKhoan,'')) = '" + strKhoaCha + "'";
            DataTable table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
            if (table.Rows.Count == 0)
            {
                return ("'" + strKhoaCha + "'");
            }
            string str3 = "'" + strKhoaCha + "'";
            int num2 = table.Rows.Count - 1;
            for (int i = 0; i <= num2; i++)
            {
                str3 = str3 + "," + this.GetListKhoaTaiKhoanCon(Conversions.ToString(table.Rows[i]["Khoa"]));
            }
            return str3;
        }

        public DataTable GetListNhom(int pCapDo)
        {
            DataTable table;
            string commandText = "";
            IDataParameter parameter = null;
            try
            {
                commandText = "SELECT Khoa, Rtrim(SoTaiKhoan) + '. ' + Rtrim(Ten" + modGeneral.H_LANGUAGE + ") as TenSoTaiKhoan, SoTaiKhoan  FROM DM_TaiKhoan WHERE CapDo = " + Conversions.ToString(pCapDo) + " AND Rtrim(LoaiPhienBan) IN ('" + modGeneral.H_PHIENBANQUYETDINH + "', 'DC') ORDER BY SoTaiKhoan ";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[] { parameter }).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public string GetTaiKhoan(string strSoTK)
        {
            string commandText = "SELECT TOP 1 Khoa FROM DM_TaiKhoan WHERE LEFT(Rtrim(SoTaiKhoan)," + Conversions.ToString(strSoTK.Trim().Length) + ") = '" + strSoTK + "' AND Khoa not in (SELECT NhomTaiKhoan FROM DM_TaiKhoan) ORDER BY SoTaiKhoan ";
            return LVYModule.ReturnIfNull(RuntimeHelpers.GetObjectValue(DBHelper.ExecuteScalar(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0])), "", modGeneral.TypeOfValue.Nothing).ToString();
        }

        public DataTable GetTaiKhoanDinhKhoan(string KhoaTaiKhoan)
        {
            DataTable table;
            string commandText = "";
            IDataParameter parameter = null;
            try
            {
                commandText = "SELECT KHOATAIKHOANNO, KHOATAIKHOANCO FROM GL_NHATKYCHUNGTU where KHOATAIKHOANNO = '" + KhoaTaiKhoan + "' or KHOATAIKHOANCO = '" + KhoaTaiKhoan + "'";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[] { parameter }).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable GetTheoNhomTaiKhoan(string NhomTaiKhoan)
        {
            DataTable table;
            string commandText = "";
            IDataParameter parameter = null;
            try
            {
                commandText = "select top 2 SOTAIKHOAN, TENVIET  from DM_taikhoan where NHOMTAIKHOAN=  '" + NhomTaiKhoan + "'";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[] { parameter }).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public bool Load(string pKhoa)
        {
            bool flag=false;
            try
            {
                string commandText = "SELECT * FROM DM_TaiKhoan WHERE Khoa = '" + pKhoa + "'";
                IDataReader dataReader = DBHelper.ExecuteReader(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]);
                if (dataReader.Read())
                {
                    this.mKhoa = Conversions.ToString(modGeneral.GetValue(dataReader, 0, modGeneral.typeOfColumn.GetString));
                    this.mPhanLoai = Conversions.ToString(modGeneral.GetValue(dataReader, 1, modGeneral.typeOfColumn.GetString));
                    this.mCapDo = Conversions.ToInteger(modGeneral.GetValue(dataReader, 2, modGeneral.typeOfColumn.GetInt32));
                    this.mNhomTaiKhoan = Conversions.ToString(modGeneral.GetValue(dataReader, 3, modGeneral.typeOfColumn.GetString));
                    this.mSoTaiKhoan = Conversions.ToString(modGeneral.GetValue(dataReader, 4, modGeneral.typeOfColumn.GetString));
                    this.mTenViet = Conversions.ToString(modGeneral.GetValue(dataReader, 5, modGeneral.typeOfColumn.GetString));
                    this.mTenAnh = Conversions.ToString(modGeneral.GetValue(dataReader, 6, modGeneral.typeOfColumn.GetString));
                    this.mBoPhan = Conversions.ToInteger(modGeneral.GetValue(dataReader, 7, modGeneral.typeOfColumn.GetInt32));
                    this.mSanPham = Conversions.ToInteger(modGeneral.GetValue(dataReader, 8, modGeneral.typeOfColumn.GetInt32));
                    this.mHopDong = Conversions.ToInteger(modGeneral.GetValue(dataReader, 9, modGeneral.typeOfColumn.GetInt32));
                    this.mCongNo = Conversions.ToInteger(modGeneral.GetValue(dataReader, 10, modGeneral.typeOfColumn.GetInt32));
                    this.mTonQuy = Conversions.ToInteger(modGeneral.GetValue(dataReader, 11, modGeneral.typeOfColumn.GetInt32));
                    this.mTheoDoiTheoDoiTuong = Conversions.ToInteger(modGeneral.GetValue(dataReader, 12, modGeneral.typeOfColumn.GetInt32));
                    this.mDoiTuongNhanVien = Conversions.ToInteger(modGeneral.GetValue(dataReader, 13, modGeneral.typeOfColumn.GetInt32));
                    this.mDoiTuongNganHang = Conversions.ToInteger(modGeneral.GetValue(dataReader, 14, modGeneral.typeOfColumn.GetInt32));
                    this.mDoiTuongCungCap = Conversions.ToInteger(modGeneral.GetValue(dataReader, 15, modGeneral.typeOfColumn.GetInt32));
                    this.mDoiTuongKhachHang = Conversions.ToInteger(modGeneral.GetValue(dataReader, 0x10, modGeneral.typeOfColumn.GetInt32));
                    this.mLoaiTien = Conversions.ToString(modGeneral.GetValue(dataReader, 0x11, modGeneral.typeOfColumn.GetString));
                    this.mLoaiTaiKhoan = Conversions.ToString(modGeneral.GetValue(dataReader, 0x12, modGeneral.typeOfColumn.GetString));
                    this.mTaiKhoanGiaThanh = Conversions.ToInteger(modGeneral.GetValue(dataReader, 0x13, modGeneral.typeOfColumn.GetInt32));
                    this.mLoaiPhienBan = Conversions.ToString(modGeneral.GetValue(dataReader, 20, modGeneral.typeOfColumn.GetString));
                }
                dataReader.Close();
                flag = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public bool LoadByCode(string pSoTaiKhoan)
        {
            bool flag=false;
            try
            {
                string commandText = "SELECT * FROM DM_TaiKhoan WHERE Rtrim(SoTaiKhoan) = '" + pSoTaiKhoan.Trim() + "'";
                IDataReader dataReader = DBHelper.ExecuteReader(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]);
                if (dataReader.Read())
                {
                    this.mKhoa = Conversions.ToString(modGeneral.GetValue(dataReader, 0, modGeneral.typeOfColumn.GetString));
                    this.mPhanLoai = Conversions.ToString(modGeneral.GetValue(dataReader, 1, modGeneral.typeOfColumn.GetString));
                    this.mCapDo = Conversions.ToInteger(modGeneral.GetValue(dataReader, 2, modGeneral.typeOfColumn.GetInt32));
                    this.mNhomTaiKhoan = Conversions.ToString(modGeneral.GetValue(dataReader, 3, modGeneral.typeOfColumn.GetString));
                    this.mSoTaiKhoan = Conversions.ToString(modGeneral.GetValue(dataReader, 4, modGeneral.typeOfColumn.GetString));
                    this.mTenViet = Conversions.ToString(modGeneral.GetValue(dataReader, 5, modGeneral.typeOfColumn.GetString));
                    this.mTenAnh = Conversions.ToString(modGeneral.GetValue(dataReader, 6, modGeneral.typeOfColumn.GetString));
                    this.mBoPhan = Conversions.ToInteger(modGeneral.GetValue(dataReader, 7, modGeneral.typeOfColumn.GetInt32));
                    this.mSanPham = Conversions.ToInteger(modGeneral.GetValue(dataReader, 8, modGeneral.typeOfColumn.GetInt32));
                    this.mHopDong = Conversions.ToInteger(modGeneral.GetValue(dataReader, 9, modGeneral.typeOfColumn.GetInt32));
                    this.mCongNo = Conversions.ToInteger(modGeneral.GetValue(dataReader, 10, modGeneral.typeOfColumn.GetInt32));
                    this.mTonQuy = Conversions.ToInteger(modGeneral.GetValue(dataReader, 11, modGeneral.typeOfColumn.GetInt32));
                    this.mTheoDoiTheoDoiTuong = Conversions.ToInteger(modGeneral.GetValue(dataReader, 12, modGeneral.typeOfColumn.GetInt32));
                    this.mDoiTuongNhanVien = Conversions.ToInteger(modGeneral.GetValue(dataReader, 13, modGeneral.typeOfColumn.GetInt32));
                    this.mDoiTuongNganHang = Conversions.ToInteger(modGeneral.GetValue(dataReader, 14, modGeneral.typeOfColumn.GetInt32));
                    this.mDoiTuongCungCap = Conversions.ToInteger(modGeneral.GetValue(dataReader, 15, modGeneral.typeOfColumn.GetInt32));
                    this.mDoiTuongKhachHang = Conversions.ToInteger(modGeneral.GetValue(dataReader, 0x10, modGeneral.typeOfColumn.GetInt32));
                    this.mLoaiTien = Conversions.ToString(modGeneral.GetValue(dataReader, 0x11, modGeneral.typeOfColumn.GetString));
                    this.mLoaiTaiKhoan = Conversions.ToString(modGeneral.GetValue(dataReader, 0x12, modGeneral.typeOfColumn.GetString));
                    this.mTaiKhoanGiaThanh = Conversions.ToInteger(modGeneral.GetValue(dataReader, 0x13, modGeneral.typeOfColumn.GetInt32));
                    this.mLoaiPhienBan = Conversions.ToString(modGeneral.GetValue(dataReader, 20, modGeneral.typeOfColumn.GetString));
                }
                dataReader.Close();
                flag = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public bool Save()
        {
            bool flag2;
            IDataParameter[] commandParameters = new IDataParameter[0x15];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@Khoa", DbType.Int64, ParameterDirection.Input, this.mKhoa);
                commandParameters[1] = DBHelper.createParameter("@PhanLoai", DbType.Int64, ParameterDirection.Input, this.mPhanLoai);
                commandParameters[2] = DBHelper.createParameter("@CapDo", DbType.Double, ParameterDirection.Input, this.mCapDo);
                commandParameters[3] = DBHelper.createParameter("@NhomTaiKhoan", DbType.Int64, ParameterDirection.Input, this.mNhomTaiKhoan);
                commandParameters[4] = DBHelper.createParameter("@SoTaiKhoan", DbType.Int64, ParameterDirection.Input, this.mSoTaiKhoan);
                commandParameters[5] = DBHelper.createParameter("@TenViet", DbType.Int64, ParameterDirection.Input, this.mTenViet);
                commandParameters[6] = DBHelper.createParameter("@TenAnh", DbType.Int64, ParameterDirection.Input, this.mTenAnh);
                commandParameters[7] = DBHelper.createParameter("@BoPhan", DbType.Double, ParameterDirection.Input, this.mBoPhan);
                commandParameters[8] = DBHelper.createParameter("@SanPham", DbType.Double, ParameterDirection.Input, this.mSanPham);
                commandParameters[9] = DBHelper.createParameter("@HopDong", DbType.Double, ParameterDirection.Input, this.mHopDong);
                commandParameters[10] = DBHelper.createParameter("@CongNo", DbType.Double, ParameterDirection.Input, this.mCongNo);
                commandParameters[11] = DBHelper.createParameter("@TonQuy", DbType.Double, ParameterDirection.Input, this.mTonQuy);
                commandParameters[12] = DBHelper.createParameter("@TheoDoiTheoDoiTuong", DbType.Double, ParameterDirection.Input, this.mTheoDoiTheoDoiTuong);
                commandParameters[13] = DBHelper.createParameter("@DoiTuongNhanVien", DbType.Double, ParameterDirection.Input, this.mDoiTuongNhanVien);
                commandParameters[14] = DBHelper.createParameter("@DoiTuongNganHang", DbType.Double, ParameterDirection.Input, this.mDoiTuongNganHang);
                commandParameters[15] = DBHelper.createParameter("@DoiTuongCungCap", DbType.Double, ParameterDirection.Input, this.mDoiTuongCungCap);
                commandParameters[0x10] = DBHelper.createParameter("@DoiTuongKhachHang", DbType.Double, ParameterDirection.Input, this.mDoiTuongKhachHang);
                commandParameters[0x11] = DBHelper.createParameter("@LoaiTien", DbType.Int64, ParameterDirection.Input, this.mLoaiTien);
                commandParameters[0x12] = DBHelper.createParameter("@LoaiTaiKhoan", DbType.Int64, ParameterDirection.Input, this.mLoaiTaiKhoan);
                commandParameters[0x13] = DBHelper.createParameter("@TaiKhoanGiaThanh", DbType.Double, ParameterDirection.Input, this.mTaiKhoanGiaThanh);
                commandParameters[20] = DBHelper.createParameter("@LoaiPhienBan", DbType.Int64, ParameterDirection.Input, this.mLoaiPhienBan);
                bool flag = DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "sp_DM_TaiKhoan", commandParameters) > 0;
                flag2 = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag2 = false;
                ProjectData.ClearProjectError();
                return flag2;
                ProjectData.ClearProjectError();
            }
            return flag2;
        }

        public string SearchByCode(string AccountNumber = "", string strKeyFilter = "", string strFiledNameFilter = "", string strCondition = "")
        {
            string str6;
            string commandText = "";
            IDataParameter parameter = null;
            string str5 = "";
            string str2 = "";
            string str = "";
            try
            {
                if (AccountNumber.Trim() != "")
                {
                    str5 = " AND RTRIM(SoTaiKhoan) = '" + AccountNumber.Trim() + "'";
                }
                if (strKeyFilter.Trim() != "")
                {
                    object instance = Strings.Split(strKeyFilter, "|", -1, CompareMethod.Binary);
                    int num2 = Information.UBound((Array) instance, 1);
                    for (int i = 0; i <= num2; i++)
                    {
                        if (str2.Trim() == "")
                        {
                            str2 = Conversions.ToString(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject("'", NewLateBinding.LateIndexGet(instance, new object[] { i }, null)), "'"));
                        }
                        else
                        {
                            str2 = Conversions.ToString(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(str2 + ",'", NewLateBinding.LateIndexGet(instance, new object[] { i }, null)), "'"));
                        }
                    }
                    str5 = str5 + " AND " + strFiledNameFilter + " IN (" + str2 + ")";
                }
                if (strCondition.Trim() != "")
                {
                    str5 = str5 + " AND " + strCondition;
                }
                commandText = "SELECT Khoa, SoTaiKhoan, Ten" + modGeneral.H_LANGUAGE + " as TenTaiKhoan  FROM DM_TaiKhoan WHERE Rtrim(LoaiPhienBan) IN ('" + modGeneral.H_PHIENBANQUYETDINH + "', 'DC') and Khoa not in (SELECT DISTINCT NhomTaiKhoan FROM DM_TaiKhoan)" + str5;
                IDataReader dataReader = DBHelper.ExecuteReader(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[] { parameter });
                if (dataReader.Read())
                {
                    str = modGeneral.GetValue(dataReader, 0, modGeneral.typeOfColumn.GetString).ToString() + "|" + modGeneral.GetValue(dataReader, 1, modGeneral.typeOfColumn.GetString).ToString() + "|" + modGeneral.GetValue(dataReader, 2, modGeneral.typeOfColumn.GetString).ToString();
                }
                dataReader.Close();
                str6 = str;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                str6 = "";
                ProjectData.ClearProjectError();
                return str6;
                ProjectData.ClearProjectError();
            }
            return str6;
        }

        public DataTable ShowList(string strKeyFilter = "", string strFiledNameFilter = "", string strCondition = "", string SoTaiKhoan = "")
        {
            DataTable table;
            string commandText = "";
            string str3 = "";
            string str = "";
            try
            {
                if (strKeyFilter.Trim() != "")
                {
                    object instance = Strings.Split(strKeyFilter, "|", -1, CompareMethod.Binary);
                    int num2 = Information.UBound((Array) instance, 1);
                    for (int i = 0; i <= num2; i++)
                    {
                        if (str.Trim() == "")
                        {
                            str = Conversions.ToString(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject("'", NewLateBinding.LateIndexGet(instance, new object[] { i }, null)), "'"));
                        }
                        else
                        {
                            str = Conversions.ToString(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(str + ",'", NewLateBinding.LateIndexGet(instance, new object[] { i }, null)), "'"));
                        }
                    }
                    str3 = " AND " + strFiledNameFilter + " IN (" + str + ")";
                }
                if (strCondition.Trim() != "")
                {
                    str3 = str3 + " AND " + strCondition;
                }
                if (SoTaiKhoan.Trim() != "")
                {
                    str3 = str3 + " AND  SOTAIKHOAN != '" + SoTaiKhoan + "'";
                }
                commandText = "SELECT Khoa, Rtrim(SoTaiKhoan) as Ma, Rtrim(Ten" + modGeneral.H_LANGUAGE + ") as Ten  FROM DM_TaiKhoan WHERE Rtrim(LoaiPhienBan) IN ('" + modGeneral.H_PHIENBANQUYETDINH + "', 'DC') and Khoa not in (SELECT DISTINCT NhomTaiKhoan FROM DM_TaiKhoan)" + str3 + " ORDER BY SoTaiKhoan";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable ShowListByField(string strFieldList, string strConditions = "", string strOrder = "")
        {
            DataTable table;
            string commandText = "";
            IDataParameter parameter = null;
            string str3 = "";
            string str = "";
            strFieldList = Strings.Replace(strFieldList, "|", ",", 1, -1, CompareMethod.Binary);
            try
            {
                if (strConditions.Trim() != "")
                {
                    str3 = " WHERE " + strConditions + " And Rtrim(LoaiPhienBan) IN ('" + modGeneral.H_PHIENBANQUYETDINH + "', 'DC') ";
                }
                if (strOrder.Trim() != "")
                {
                    str = " ORDER BY " + strOrder;
                }
                commandText = " SELECT " + strFieldList + "  FROM DM_TaiKhoan" + str3 + str;
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[] { parameter }).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public int BoPhan
        {
            get
            {
                return this.mBoPhan;
            }
            set
            {
                this.mBoPhan = value;
            }
        }

        public int CapDo
        {
            get
            {
                return this.mCapDo;
            }
            set
            {
                this.mCapDo = value;
            }
        }

        public int CongNo
        {
            get
            {
                return this.mCongNo;
            }
            set
            {
                this.mCongNo = value;
            }
        }

        public int DoiTuongCungCap
        {
            get
            {
                return this.mDoiTuongCungCap;
            }
            set
            {
                this.mDoiTuongCungCap = value;
            }
        }

        public int DoiTuongKhachHang
        {
            get
            {
                return this.mDoiTuongKhachHang;
            }
            set
            {
                this.mDoiTuongKhachHang = value;
            }
        }

        public int DoiTuongNganHang
        {
            get
            {
                return this.mDoiTuongNganHang;
            }
            set
            {
                this.mDoiTuongNganHang = value;
            }
        }

        public int DoiTuongNhanVien
        {
            get
            {
                return this.mDoiTuongNhanVien;
            }
            set
            {
                this.mDoiTuongNhanVien = value;
            }
        }

        public int HopDong
        {
            get
            {
                return this.mHopDong;
            }
            set
            {
                this.mHopDong = value;
            }
        }

        public string Khoa
        {
            get
            {
                return this.mKhoa;
            }
            set
            {
                this.mKhoa = value;
            }
        }

        public string LoaiPhienBan
        {
            get
            {
                return this.mLoaiPhienBan;
            }
            set
            {
                this.mLoaiPhienBan = value;
            }
        }

        public string LoaiTaiKhoan
        {
            get
            {
                return this.mLoaiTaiKhoan;
            }
            set
            {
                this.mLoaiTaiKhoan = value;
            }
        }

        public string LoaiTien
        {
            get
            {
                return this.mLoaiTien;
            }
            set
            {
                this.mLoaiTien = value;
            }
        }

        public string NhomTaiKhoan
        {
            get
            {
                return this.mNhomTaiKhoan;
            }
            set
            {
                this.mNhomTaiKhoan = value;
            }
        }

        public string PhanLoai
        {
            get
            {
                return this.mPhanLoai;
            }
            set
            {
                this.mPhanLoai = value;
            }
        }

        public int SanPham
        {
            get
            {
                return this.mSanPham;
            }
            set
            {
                this.mSanPham = value;
            }
        }

        public string SoTaiKhoan
        {
            get
            {
                return this.mSoTaiKhoan;
            }
            set
            {
                this.mSoTaiKhoan = value;
            }
        }

        public int TaiKhoanGiaThanh
        {
            get
            {
                return this.mTaiKhoanGiaThanh;
            }
            set
            {
                this.mTaiKhoanGiaThanh = value;
            }
        }

        public string TenAnh
        {
            get
            {
                return this.mTenAnh;
            }
            set
            {
                this.mTenAnh = value;
            }
        }

        public string TenViet
        {
            get
            {
                return this.mTenViet;
            }
            set
            {
                this.mTenViet = value;
            }
        }

        public int TheoDoiTheoDoiTuong
        {
            get
            {
                return this.mTheoDoiTheoDoiTuong;
            }
            set
            {
                this.mTheoDoiTheoDoiTuong = value;
            }
        }

        public int TonQuy
        {
            get
            {
                return this.mTonQuy;
            }
            set
            {
                this.mTonQuy = value;
            }
        }
    }
}

